Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't consider arrays as a special case in DifferentiateVarDecl #1164

Merged
merged 2 commits into from
Dec 8, 2024

Conversation

PetroZarytskyi
Copy link
Collaborator

This PR improves the support for array types in getZeroInit and simplifies DifferentiateVarDecl using that change.

Note: most of the diff comes from the change in indentation

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.55%. Comparing base (b6ad4ea) to head (701aa1b).
Report is 2 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1164      +/-   ##
==========================================
- Coverage   94.55%   94.55%   -0.01%     
==========================================
  Files          51       51              
  Lines        8923     8919       -4     
==========================================
- Hits         8437     8433       -4     
  Misses        486      486              
Files with missing lines Coverage Δ
lib/Differentiator/ReverseModeVisitor.cpp 95.55% <100.00%> (-0.02%) ⬇️
lib/Differentiator/VisitorBase.cpp 97.64% <100.00%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
lib/Differentiator/ReverseModeVisitor.cpp 95.55% <100.00%> (-0.02%) ⬇️
lib/Differentiator/VisitorBase.cpp 97.64% <100.00%> (+<0.01%) ⬆️

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

}
if (promoteToFnScope) {
if (promoteToFnScope)
if (const auto* AT = dyn_cast<ArrayType>(VDType))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "clang::dyn_cast" is directly included [misc-include-cleaner]

      if (const auto* AT = dyn_cast<ArrayType>(VDType))
                           ^

@@ -410,12 +410,13 @@ namespace clad {

Expr* VisitorBase::getZeroInit(QualType T) {
// FIXME: Consolidate other uses of synthesizeLiteral for creation 0 or 1.
if (T->isVoidType())
if (T->isVoidType() || isa<VariableArrayType>(T))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "clang::VariableArrayType" is directly included [misc-include-cleaner]

lib/Differentiator/VisitorBase.cpp:28:

- #include <numeric>
+ #include <clang/AST/Type.h>
+ #include <numeric>

return Zero.get();
if ((T->isScalarType() || T->isPointerType()) && !T->isReferenceType())
return ConstantFolder::synthesizeLiteral(T, m_Context, /*val=*/0);
if (isa<ConstantArrayType>(T)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "clang::ConstantArrayType" is directly included [misc-include-cleaner]

    if (isa<ConstantArrayType>(T)) {
            ^

Copy link
Owner

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@vgvassilev vgvassilev merged commit eee6faa into vgvassilev:master Dec 8, 2024
90 checks passed
@PetroZarytskyi PetroZarytskyi deleted the arr-init branch December 9, 2024 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants